package com.bwie.gateway.config;

import com.google.common.hash.BloomFilter;
import com.google.common.hash.Funnels;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.nio.charset.Charset;

/**
 * @Author JunChenNi
 * @Date 2025/2/28 17:10
 * @ClassName BloomFilterConfig
 * @Description bloom过滤器配置类
 */
@Configuration
public class BloomFilterConfig {

    @Bean
    public BloomFilter<String> stringbloomFilter(){
        Charset charset = Charset.forName("UTF-8");
        BloomFilter bloomFilter = BloomFilter.create(Funnels.stringFunnel(charset),10000000,0.01);
        return bloomFilter;
    }

    @Bean
    public BloomFilter<Integer> intbloomFilter(){
//        Charset charset = Charset.forName("UTF-8");
        BloomFilter bloomFilter = BloomFilter.create(Funnels.integerFunnel(),10000000,0.01);
        return bloomFilter;
    }
}
